package com.yanqu.road.server.cmd.activity.langyabang;

import com.yanqu.road.entity.player.UserBaseInfo;
import com.yanqu.road.logic.pb.PlayerBasePb;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.LangYaBangProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.cmd.CrossUnionCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.user.CrossUserMgr;
import com.yanqu.road.server.protocol.CrossProtocol;

@Cmd(code = CrossProtocol.C_LANG_YA_LOGIN_SEND_DATA_TO_CROSS,desc = "登录上传消息")
public class CrossLangYaLoginCmd extends CrossUnionCommand {
    private UserBaseInfo userBaseInfo;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        LangYaBangProto.LoginSendToCrossMsg loginSendToCrossMsg = LangYaBangProto.LoginSendToCrossMsg.parseFrom(packet.getBytes());
        userBaseInfo = PlayerBasePb.parseToUserBaseInfo(loginSendToCrossMsg.getUserBaseInfo());
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        CrossUserMgr.updateUserBaseInfo(packet.getPlayerId(),userBaseInfo);
    }

    @Override
    public void sendData() {

    }
}
